<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function maxr(str) {
            var o = {}
            var entry = ['', 0]
            for (var c of str) {
                if (c in o) {
                    o[c] = o[c] + 1
                } else {
                    o[c] = 1
                }
                if (o[c] > entry[1]) {
                    entry[0] = c
                    entry[1] = o[c]
                }
            }
            return entry[0].repeat(entry[1])
        }

        console.log(maxr('mmmiijjjjkkkkkkssptr'))
    </script>
</body>
</html>